﻿// ====================================
// Created By Angie.D 2010.6
// ====================================

using System;
using System.Collections.Generic;
using System.Text;

using System.Windows.Forms;

namespace WOWMultiPlay
{
    public class VKFinderTextBox : TextBox
    {
        public enum ResultMode
        {
            Normal,
            KeyArray,
        }

        private ResultMode _resultShowMode = ResultMode.Normal;
        public ResultMode ResultShowMode
        {
            get
            {
                return _resultShowMode;
            }

            set
            {
                _resultShowMode = value;
            }
        }

        private bool _watchKeyPress = false;
        public bool WatchKeyPress
        {
            get
            {
                return _watchKeyPress;
            }

            set
            {
                _watchKeyPress = value;
            }
        }

        private int pressedKey;

        protected override void WndProc(ref Message msg)
        {
            if (WatchKeyPress && msg.Msg == WindowsAPI.WM.WM_KEYDOWN)
            {
                pressedKey = msg.WParam.ToInt32();

                switch (ResultShowMode)
                {
                    case ResultMode.Normal:
                        this.Text = Common.GetVKName(pressedKey);
                        break;
                    case ResultMode.KeyArray:
                        this.Text += "{" + Common.GetVKName(pressedKey) + ",DU}";
                        break;
                    default:
                        break;
                }
            }
            else
            {
                base.WndProc(ref msg);
            }
        }
    }
}
